import dashscope
import os

def IsResponseTime(li) -> bool:
    return li.startswith("response time")


dashscope.api_key = "sk-da1d85ca047141b2b609854ead685cb8"

read_folder_path = "../Tongyiqianwen"
write_folder_path = '../zuowentemp'

write_file_path = os.path.join(write_folder_path, 'cal.txt')
for root, dirs, files in os.walk(read_folder_path):
    for file in files:
        file_path = os.path.join(root, file)
        with open(file_path, 'r', encoding='utf-8') as f:
            lines = f.readlines()
            for line in lines:
                if IsResponseTime(line):
                    with open(write_file_path, 'a', encoding='utf-8') as write_file:
                        write_file.write(f"{file}:  {line}")
